package com.xbongbong.pro.statistic.help.strategy.method;

import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.statistic.help.FieldAnalysisHelp;
import com.xbongbong.pro.statistic.help.strategy.field.FieldAnalysisStrategy;
import com.xbongbong.pro.statistic.pojo.FieldAnalysisPojo;
import com.xbongbong.saas.service.toolbox.help.FundSetHelp;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zcp
 */

@Component
public class ReceivablePeriodFieldAnalysis implements FieldAnalysisStrategy {
    @Resource
    public FieldAnalysisHelp fieldAnalysisHelp;
    @Resource
    private FundSetHelp fundSetHelp;

    @Override
    public Map<String, String> doAnalysisField(FieldAnalysisPojo fieldAnalysisPojo) throws XbbException {
        Map<String, String> results = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        List<String> values = fieldAnalysisPojo.getValues();
        List<String> valuesResult = fieldAnalysisPojo.getValuesResult();
        for (int i = 0; i < values.size(); i++) {
            results.put(values.get(i), fundSetHelp.getFormatReceivablePeriod(valuesResult.get(i)));
        }
        return results;
    }
}
